package org.groupg.practice.guiPractice.awt;

import java.awt.*;

public class GridLayoutTest {
    public static void main(String[] args) {
        var f = new Frame("计算器");
        var p1 = new Panel();
        p1.add(new TextField("123123123",30));
        f.add(p1, BorderLayout.NORTH);
        Panel p2 = new Panel();
        // 设置Panel使用GridLayout布局管理器
        p2.setLayout(new GridLayout(3, 5, 10, 10));
        String[] name = {"0", "1", "2", "3",
                "4", "5", "6", "7", "8", "9",
                "+", "-", "＊", "/", "."};
        // 向Panel中依次添加15个按钮
        for (String s : name) {
            p2.add(new Button(s));
        }
        // 默认将Panel对象添加到Frame窗口的中间
        f.add(p2);
        // 设置窗口为最佳大小
        f.pack();
        // 将窗口显示出来（Frame对象默认处于隐藏状态）
        f.setVisible(true);

        System.exit(0);
    }
}